package com.sws.web.controller.ry_rongyue.reservation;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sws.common.annotation.Log;
import com.sws.common.core.controller.BaseController;
import com.sws.common.core.domain.AjaxResult;
import com.sws.common.enums.BusinessType;
import com.sws.reservation.domain.RyReservation;
import com.sws.reservation.service.IRyReservationService;
import com.sws.common.utils.poi.ExcelUtil;
import com.sws.common.core.page.TableDataInfo;

/**
 * 用户预约服务Controller
 * 
 * @author cx
 * @date 2025-06-30
 */
@RestController
@RequestMapping("/ry/reservation/reservation")
public class RyReservationController extends BaseController
{
    @Autowired
    private IRyReservationService ryReservationService;

    /**
     * 查询用户预约服务列表
     */
    @PreAuthorize("@ss.hasPermi('ry/reservation:reservation:list')")
    @GetMapping("/list")
    public TableDataInfo list(RyReservation ryReservation)
    {
        startPage();
        List<RyReservation> list = ryReservationService.selectRyReservationList(ryReservation);
        return getDataTable(list);
    }

    /**
     * 导出用户预约服务列表
     */
    @PreAuthorize("@ss.hasPermi('ry/reservation:reservation:export')")
    @Log(title = "用户预约服务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RyReservation ryReservation)
    {
        List<RyReservation> list = ryReservationService.selectRyReservationList(ryReservation);
        ExcelUtil<RyReservation> util = new ExcelUtil<RyReservation>(RyReservation.class);
        util.exportExcel(response, list, "用户预约服务数据");
    }

    /**
     * 获取用户预约服务详细信息
     */
    @PreAuthorize("@ss.hasPermi('ry/reservation:reservation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ryReservationService.selectRyReservationById(id));
    }

    /**
     * 新增用户预约服务
     */
    @PreAuthorize("@ss.hasPermi('ry/reservation:reservation:add')")
    @Log(title = "用户预约服务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RyReservation ryReservation)
    {
        return toAjax(ryReservationService.insertRyReservation(ryReservation));
    }

    /**
     * 修改用户预约服务
     */
    @PreAuthorize("@ss.hasPermi('ry/reservation:reservation:edit')")
    @Log(title = "用户预约服务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RyReservation ryReservation)
    {
        return toAjax(ryReservationService.updateRyReservation(ryReservation));
    }

    /**
     * 删除用户预约服务
     */
    @PreAuthorize("@ss.hasPermi('ry/reservation:reservation:remove')")
    @Log(title = "用户预约服务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ryReservationService.deleteRyReservationByIds(ids));
    }
}
